package com.fxd.springcloud.controller;

import com.fxd.springcloud.entities.CommonResult;
import com.fxd.springcloud.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @auther fuxudong
 * @date 2021/4/26 - 19:15
 */
@RestController
@Slf4j
public class OrderConsulController {

//    public static final String PAYMENT_URL = "http://localhost:8001";
    //根据服务名称找，不能写死，且该服务具备负载均衡功能了
    public static final String PAYMENT_URL = "http://consul-provider-payment";

    @Resource
    private RestTemplate restTemplate;

    @GetMapping("/consumer/payment/consul")
    public String create() {

        //参数一：调用的地址
        //参数二：参数
        //参数三：结果集
        return restTemplate.getForObject(PAYMENT_URL + "/payment/consul", String.class);
    }



}
